<?php
/**
 * Created by PhpStorm.
 * User: geolo
 * Date: 2018/11/20
 * Time: 17:04
 */
namespace app\modules\mch\models;
use app\models\Vip;

/**
 * Class VipForm
 *  @property Vip $model
 */
class VipForm extends Model
{
    public $store_id;
    public $money;
    public $model;

    public function rules(){
        return [
            [['money','store_id'],'required'],
            [['store_id'],'integer'],
            [['money'],'double'],
        ];
    }

    public function attributeLabels()
    {
        return[
            ['store_id'=>'商城id'],
            ['money'=>'金额'],
        ];
    }
    public function save()
    {
        if (!$this->validate()) {
            return $this->getModelError();
        }
        $this->model->money = $this->money;
        if ($this->model->isNewRecord) {
            $this->model->store_id = $this->store_id;
        }
        if ($this->model->save())
            return [
                'code' => 0,
                'msg' => '保存成功',
            ];
        else
            return $this->getModelError($this->model);
    }
}